package org.crud4j.core;

/**
 * Listener of crud write operations
 */
public interface CrudListener {

	/**
	 * Callback method used to notify creation events
	 * 
	 * @param user
	 *            the user that fires the event
	 * @param bean
	 *            the modified bean
	 * @throws BeforeCreateException
	 *             if the listener rejects the persist operation
	 */
	public void onCreate(String user, Object bean) throws BeforeCreateException;

	/**
	 * Callback method used to notify update events
	 * 
	 * @param user
	 *            the user that fires the event
	 * @param bean
	 *            the modified bean
	 * @throws BeforeUpdateException
	 *             if the listener rejects the persist operation
	 */
	public void onUpdate(String user, Object beanBefore, Object beanAfter)
			throws BeforeUpdateException;

	/**
	 * Callback method used to notify remove events
	 * 
	 * @param user
	 *            the user that fires the event
	 * @param bean
	 *            the modified bean
	 * @throws BeforeRemoveException
	 *             if the listener rejects the persist operation
	 */
	public void onRemove(String user, Object bean)
			throws BeforeRemoveException;

}
